
<%@page import="Business.Customer"%>
<%@page import="java.text.NumberFormat"%>
<%@page import="java.text.NumberFormat"%>
<%@page import="Business.LineItem"%>
<%@page import="Business.Cart"%>
<%@page import="Business.Order"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<%@include file="WEB-INF/jspf/header.jspf"%>

<%
    Order order = (Order) session.getAttribute("order");
    Customer customer  = order.getCustomer();
    if(!customer.checkCustomerExist())
        customer.save();
    order.save();
    Cart cart = (Cart) session.getAttribute("cart");
    ArrayList<LineItem> list = cart.getItems();
    NumberFormat nf = NumberFormat.getInstance();
    //nf.setMinimumFractionDigits(2);
    nf.setMaximumFractionDigits(2);
%>

<div id="content">

    <div id="hello">
        <div>
            <div style="width:150px;float:left;"><img width="150" src="images/design/shopping.png" /></div><div style="width:auto;float:right"><h3 style="color:#ff9900;">Xác nhận mua hàng: click “Đặt mua hàng”</h3>                                

                Địa chỉ Giao hàng : <b><%=order.getCustomer().getAddress()%></b>	<br>
                Họ tên: <b><%=order.getCustomer().getName()%></b><br>
                Điện thoại: <b><%=order.getCustomer().getPhoneNumber()%></b><br>                                
                Phương  thức thanh toán: <b><%=order.getPaytype()%></b><br>
                Ghi chú:<b><%=order.getNote()%></b><br>

            </div>

            <table width="100%" border="0" cellspacing="0" cellpadding="5" style="clear:both;">
                <tr >
                    <th align="center" class="borderheader" scope="col">ẢNH	</th>
                    <th align="center" class="borderheader" scope="col">SẢN PHẨM</th>
                    <th align="center" class="borderheader" scope="col">GIÁ</th>
                    <th align="center" class="borderheader" scope="col">SỐ LƯỢNG</th>
                    <th align="center" class="borderheader" scope="col">THÀNH TIỀN</th>
                </tr>
                <%
                    for (LineItem item : list) {
                %>                                 
                <tr>
                    <td align="center" valign="middle">
                        <img src="<%=item.getProduct().getImage()%>" width="59" height="88" /></td>
                    <td align="center" ><%=item.getProduct().getProductCode()%></td>
                    <td align="center"><span class="style1"><%=nf.format(item.getProduct().getPrice())%> VND</span></td>
                    <td align="center"><%=item.getQuantity()%></td>
                    <td align="center"><span class="style1"><%=nf.format(item.getTotal())%> VND</span></td>
                </tr>

                <%
                    }
                %>
                <tr>
                    <td colspan="4">&nbsp;</td>
                    <td><strong>Tiền mua hàng   <%=nf.format(order.getTotal())%>  VND</strong></td>
                </tr>
                
                <tr>
                    <td colspan="4"></td>
                    <td>
                        <div style=
                             "border: solid 0 #2A82DB; border-top-width:2px; padding:5px;">
                            <strong>Tổng cộng: <span class="style1"><%=nf.format(order.getTotal())%> VND</span></strong>                                        </div>                                    </td>
                </tr>

                <tr align="center">
                    <td colspan="6"><form action="ConfirmPayment" method="get">


                            <input name="pay" type="button" value="Xác Nhận" onclick="window.location='index.jsp'"/>
                        </form></td>
                </tr>
            </table>

        </div>

    </div>


</div>
<%@include file="WEB-INF/jspf/footer.jspf" %>